home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include "PrefDialog.h"
- #include "VCal.h"
- #include "Preferences.h"
- #include <Vk/VkPrefItem.h>
- #include <Vk/VkWarningDialog.h>
-
- PrefDialog::PrefDialog(VCal *o, Preferences *p, const char *name)
- : VkPrefDialog(name)
- {
- owner = o;
- pref = p;
-
- list = new VkPrefList("preferences");
- alarmGroup = new VkPrefGroup("alarmGroup", True);
- alarmExtra = new VkPrefGroup("alarmExtra", False, True);
- dayGroup = new VkPrefGroup("dayGroup", True);
- day1 = new VkPrefGroup("day1", False, True);
- day2 = new VkPrefGroup("day2", False, True);
- day3 = new VkPrefGroup("day3", False, True);
- configGroup = new VkPrefGroup("configGroup", True);
- config1 = new VkPrefGroup("config1", False, True);
- config2 = new VkPrefGroup("config2", False, True);
- config3 = new VkPrefGroup("config3", False, True);
- saveGroup = new VkPrefGroup("saveGroup");
- filename = new VkPrefText("filename", 40);
- advance = new VkPrefText("advance");
- update = new VkPrefText("update");
- snooze = new VkPrefText("snooze");
- lates = new VkPrefToggle("latest", True);
- autoSave = new VkPrefToggle("autoSave", True);
- annotate = new VkPrefToggle("annotate", True);
- updateIcon = new VkPrefToggle("updateIcon", True);
- updateIconDate = new VkPrefToggle("updateIconDate", True);
- clock24 = new VkPrefToggle("clock24", True);
- alarm1 = new VkPrefGroup("alarm1", False, True);
- alarm2 = new VkPrefGroup("alarm2", False, True);
- alarm3 = new VkPrefGroup("alarm3", False, True);
- alarms = new VkPrefToggle("alarms", True);
- notifyPopup = new VkPrefToggle("notifyPopup", True);
- notifyBell = new VkPrefToggle("notifyBell", True);
- notifyConfirmDelete = new VkPrefToggle("notifyConfirmDelete", True);
- notifyMail = new VkPrefToggle("notifyMail", True);
- notifyCommand = new VkPrefText("notifyCommand", 40);
- annotateDay = new VkPrefToggle("annotateDay", True);
- hideMenu = new VkPrefToggle("hideMenu", True);
- annotateMonth = new VkPrefToggle("annotateMonth", True);
- restricted = new VkPrefToggle("restricted", True);
- apptLength = new VkPrefText("apptLength");
- gridLength = new VkPrefText("gridLength");
- apptSubdiv = new VkPrefText("apptSubdiv");
- snapInterval = new VkPrefText("snapInterval");
- restrictStart = new VkPrefText("restrictStart");
- restrictStop = new VkPrefText("restrictStop");
- space1 = new VkPrefEmpty();
- space2 = new VkPrefEmpty();
- space3 = new VkPrefEmpty();
-
- config1->addItem(hideMenu);
- config1->addItem(updateIcon);
- config1->addItem(updateIconDate);
- config2->addItem(annotateMonth);
- config2->addItem(lates);
- config2->addItem(clock24);
- config3->addItem(snooze);
- config3->addItem(update);
- configGroup->addItem(config1);
- configGroup->addItem(config2);
- configGroup->addItem(config3);
- alarmGroup->addItem(alarm1);
- alarmGroup->addItem(alarm2);
- alarmGroup->addItem(alarm3);
- alarm1->addItem(alarms);
- alarm1->addItem(annotateDay);
- alarm2->addItem(notifyPopup);
- alarm2->addItem(notifyBell);
- alarm3->addItem(notifyConfirmDelete);
- alarm3->addItem(notifyMail);
- alarmExtra->addItem(notifyCommand);
- alarmExtra->addItem(advance);
- day1->addItem(apptLength);
- day1->addItem(gridLength);
- day2->addItem(apptSubdiv);
- day2->addItem(snapInterval);
- day3->addItem(restricted);
- day3->addItem(restrictStart);
- day3->addItem(restrictStop);
- dayGroup->addItem(day1);
- dayGroup->addItem(day2);
- dayGroup->addItem(day3);
- saveGroup->addItem(filename);
- saveGroup->addItem(annotate);
- saveGroup->addItem(autoSave);
-
- list->addItem(configGroup);
- list->addItem(space1);
- list->addItem(alarmGroup);
- list->addItem(alarmExtra);
- list->addItem(space2);
- list->addItem(dayGroup);
- list->addItem(space3);
- list->addItem(saveGroup);
-
- setItem(list);
- updateDisplay();
- }
-
- PrefDialog::~PrefDialog()
- {
- list->deleteChildren();
- delete list;
- }
-
- /**********************************************************************/
-
- void
- PrefDialog::updateDisplay()
- {
- char str[256];
-
- alarms->setValue(pref->alarms());
- notifyPopup->setValue(pref->notifyPopup());
- notifyBell->setValue(pref->notifyBell());
- notifyConfirmDelete->setValue(pref->notifyConfirmDelete());
- notifyMail->setValue(pref->notifyMail());
- notifyCommand->setValue(pref->notifyCommand());
- annotateDay->setValue(pref->annotateDay());
- advance->setValue(pref->advanceWarning());
- sprintf(str, "%d", pref->snoozeMinutes());
- snooze->setValue(str);
- hideMenu->setValue(pref->hideMenuBar());
- updateIcon->setValue(pref->updateIconName());
- updateIconDate->setValue(pref->updateIconDate());
- clock24->setValue(pref->clock24());
- lates->setValue(pref->showLates());
- sprintf(str, "%d", pref->updateInterval());
- update->setValue(str);
- filename->setValue(pref->filename());
- autoSave->setValue(pref->saveChangesAutomatically());
- annotate->setValue(pref->annotateFile());
- annotateMonth->setValue(pref->annotateMonth());
- restricted->setValue(pref->restricted());
- sprintf(str, "%d", pref->apptLength());
- apptLength->setValue(str);
- sprintf(str, "%d", pref->gridLength());
- gridLength->setValue(str);
- sprintf(str, "%d", pref->apptSubdiv());
- apptSubdiv->setValue(str);
- sprintf(str, "%d", pref->snapInterval());
- snapInterval->setValue(str);
- sprintf(str, "%d", pref->restrictStart());
- restrictStart->setValue(str);
- sprintf(str, "%d", pref->restrictStop());
- restrictStop->setValue(str);
-
- list->updateValue();
- }
-
- /**********************************************************************/
-
- void
- PrefDialog::apply(Widget, XtPointer)
- {
- Boolean changed;
- int num;
-
- changed = False;
- if (filename->changed()) {
- pref->setFilename(filename->getValue());
- changed = True;
- }
- if (advance->changed()) {
- pref->setAdvanceWarning(advance->getValue());
- // add units
- advance->setValue(pref->advanceWarning());
- changed = True;
- }
- if (update->changed()) {
- if ((num = atoi(update->getValue())) > 0) {
- pref->setUpdateInterval(num);
- changed = True;
- } else {
- theWarningDialog->post("Illegal update interval.");
- }
- }
- if (lates->changed()) {
- pref->setShowLates(lates->getValue());
- changed = True;
- }
- if (autoSave->changed()) {
- pref->setSaveChangesAutomatically(autoSave->getValue());
- changed = True;
- }
- if (annotate->changed()) {
- pref->setAnnotateFile(annotate->getValue());
- changed = True;
- }
- if (updateIcon->changed()) {
- pref->setUpdateIconName(updateIcon->getValue());
- changed = True;
- }
- if (updateIconDate->changed()) {
- pref->setUpdateIconDate(updateIconDate->getValue());
- changed = True;
- }
- if (clock24->changed()) {
- pref->setClock24(clock24->getValue());
- changed = True;
- }
- if (alarms->changed()) {
- pref->setAlarms(alarms->getValue());
- changed = True;
- }
- if (notifyPopup->changed()) {
- pref->setNotifyPopup(notifyPopup->getValue());
- changed = True;
- }
- if (notifyBell->changed()) {
- pref->setNotifyBell(notifyBell->getValue());
- changed = True;
- }
- if (notifyMail->changed()) {
- pref->setNotifyMail(notifyMail->getValue());
- changed = True;
- }
- if (notifyConfirmDelete->changed()) {
- pref->setNotifyConfirmDelete(notifyConfirmDelete->getValue());
- changed = True;
- }
- if (notifyCommand->changed()) {
- pref->setNotifyCommand(notifyCommand->getValue());
- changed = True;
- }
- if (annotateDay->changed()) {
- pref->setAnnotateDay(annotateDay->getValue());
- changed = True;
- }
- if (snooze->changed()) {
- if ((num = atoi(snooze->getValue())) > 0) {
- pref->setSnoozeMinutes(num);
- changed = True;
- } else {
- theWarningDialog->post("Illegal snooze time.");
- }
- }
- if (hideMenu->changed()) {
- pref->setHideMenuBar(hideMenu->getValue());
- changed = True;
- if (pref->hideMenuBar()) {
- theWarningDialog->post("Menu bar will be hidden the next time you run vcal.");
- } else {
- theWarningDialog->post("Menu bar will be displayed the next time you run vcal.");
- }
- }
- if (annotateMonth->changed()) {
- pref->setAnnotateMonth(annotateMonth->getValue());
- changed = True;
- }
- if (restricted->changed()) {
- pref->setRestricted(restricted->getValue());
- changed = True;
- }
- if (apptLength->changed()) {
- if ((num = atoi(apptLength->getValue())) > 0) {
- pref->setApptLength(num);
- changed = True;
- } else {
- theWarningDialog->post("Illegal appointment length time.");
- }
- }
- if (gridLength->changed()) {
- if ((num = atoi(gridLength->getValue())) > 0) {
- pref->setGridLength(num);
- changed = True;
- } else {
- theWarningDialog->post("Illegal grid entry length.");
- }
- }
- if (apptSubdiv->changed()) {
- if ((num = atoi(apptSubdiv->getValue())) > 0) {
- pref->setApptSubdiv(num);
- changed = True;
- } else {
- theWarningDialog->post("Illegal number of grid subdivisions.");
- }
- }
- if (snapInterval->changed()) {
- if ((num = atoi(snapInterval->getValue())) > 0) {
- pref->setSnapInterval(num);
- changed = True;
- } else {
- theWarningDialog->post("Illegal grid snap interval.");
- }
- }
- if (restrictStart->changed()) {
- if ((num = atoi(restrictStart->getValue())) > 0) {
- pref->setRestrictStart(num);
- changed = True;
- } else {
- theWarningDialog->post("Illegal restricted start hour.");
- }
- }
- if (restrictStop->changed()) {
- if ((num = atoi(restrictStop->getValue())) > 0) {
- pref->setRestrictStop(num);
- changed = True;
- } else {
- theWarningDialog->post("Illegal restricted stop hour.");
- }
- }
- if (changed) {
- owner->prefChanged();
- }
- }
-